SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS qm_user_study;
CREATE TABLE qm_user_study(
	id int(10) NOT NULL AUTO_INCREMENT COMMENT '编号',
	user_id int(10) not NULL COMMENT '用户编号',
	app VARCHAR(15) NOT NULL COMMENT '所属表名',
	app_id int(10) NOT NULL COMMENT '资源ID',
	chapter_id int(10) NOT NULL DEFAULT 0 COMMENT '当前章节编号',
	content_id  int(10) NOT NULL DEFAULT 0 COMMENT '当前小节编号',
	chapter_num TINYINT(2) NOT NULL DEFAULT 0 COMMENT '当前学习章节',
	chapters TINYINT(2) NOT NULL DEFAULT 0 COMMENT '课程总章节',
	price MEDIUMINT(6) NOT NULL DEFAULT 0 COMMENT '所花积分',
	finished TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已学完',
	finished_at datetime COMMENT '完成时间',
	created_at datetime DEFAULT CURRENT_TIMESTAMP COMMENT '开始学习时间',
	updated_at datetime DEFAULT CURRENT_TIMESTAMP COMMENT '再次学习时间',
	deleted_at datetime COMMENT '删除学习课程时间',
	PRIMARY KEY(id),
	UNIQUE KEY (user_id,app,app_id)
); 
ALTER TABLE qm_user_other ADD views_num int(10) NOT NULL DEFAULT 0 COMMENT '用户主页浏览量，人气';

ALTER TABLE qm_employ_ext ADD price MEDIUMINT(6) NOT NULL DEFAULT 0 COMMENT '阅读所需积分';

ALTER TABLE qm_company_inbox ADD updated_at datetime;


ALTER TABLE qm_company ADD is_validate TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否通过审核 1:审核通过；0:未审核；2：审核不通过；默认 0';
ALTER TABLE qm_company ADD validated_at datetime COMMENT '审核时间';
ALTER TABLE qm_users ADD shenfen VARCHAR(100) DEFAULT '' COMMENT '身份显示';
ALTER TABLE `qingmu`.`qm_user_experience` CHANGE COLUMN `start_at` `start_at` varchar(10) NOT NULL COMMENT '开始时间', CHANGE COLUMN `end_at` `end_at` varchar(10) NOT NULL COMMENT '结束时间';
ALTER TABLE `qingmu`.`qm_user_projects` CHANGE COLUMN `start_at` `start_at` varchar(10) NOT NULL COMMENT '项目起始时间', CHANGE COLUMN `end_at` `end_at` varchar(10) NOT NULL COMMENT '项目截至时间';
ALTER TABLE qm_user_other ADD expect_province int(10) DEFAULT 0 COMMENT '期望的省';


-- ----------------------------
--  Table structure for `qm_group`
-- ----------------------------
DROP TABLE IF EXISTS `qm_group`;
CREATE TABLE `qm_group` (
  `id` mediumint(6) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL COMMENT '组名',
  `display_name` varchar(100) NOT NULL DEFAULT '' COMMENT '介绍',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `qm_group`
-- ----------------------------
BEGIN;
INSERT INTO `qm_group` VALUES ('1', 'admin', '后台管理组'), ('2', 'company', '企业用户'), ('3', 'users', '前端用户');
COMMIT;

-- ----------------------------
--  Table structure for `qm_group_role`
-- ----------------------------
DROP TABLE IF EXISTS `qm_group_role`;
CREATE TABLE `qm_group_role` (
  `group_id` int(11) NOT NULL DEFAULT '0',
  `role_id` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`group_id`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `qm_group_role`
-- ----------------------------
BEGIN;
INSERT INTO `qm_group_role` VALUES ('1', '1'), ('1', '2'), ('2', '4'), ('3', '3');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;

